<?php
	include("../include/init.php");//将配置文件全部加载进来
	include("../include/check_login.php");//登录

	$insert = new sql_class("user");
	$login_time = date("Y-m-d H:i:s");

	$user_id = isset($_GET['user_id']) ? $_GET['user_id'] : 0;

	if(!$user_id){
		show_msg("请重新选择","user_list.php");
		exit;
	}
	$where = "user_id = $user_id";
	$user_one = $insert->select($where)->getOne();

	if($_POST){
		$data = array(
					"user_phone"=>trim($_POST['user_phone']),
					"user_login"=>strtotime($_POST['user_login']),
				);
		if(!empty($_POST['user_pw'])){
			$data['user_pw'] = md5($_POST['user_pw']);
		}
		$where = "user_id = $user_id";
		$insert_id = $insert->update($data,$where);
		if($insert_id){
			show_msg("更新用户成功","user_list.php");
			exit;
		}else{
			show_msg("更新用户失败","user_edit.php?user_id = $user_id");
			exit;
		}
	}
	
	$smarty->assign("user_one",$user_one);
	$smarty->assign("login_time",$login_time);
	$smarty->display("admin/user_edit.html");//连接index.html



?>